<?php
/**
 * Copyright (C), 2021-2021, Shall Buy Life info. Co., Ltd.
 * FileName: MicroProvider.php
 * Description: 调用其他服务api 的 服务提供者
 *
 * @author lwl
 * @Create Date    2021/9/2 21:01
 * @Update Date    2021/9/2 21:01 By lwl
 * @version v1.0
 */
namespace App\Providers;

use Example\Constants\MicroConstant;
use Example\Services\MicroService;
use Illuminate\Support\ServiceProvider;

class MicroServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        //使用singleton绑定单例
        $this->app->singleton('micro', function () {
            return new MicroService();
        });

        //使用bind绑定实例到接口以便依赖注入
        $this->app->bind(MicroConstant::class, function () {
            return new MicroService();
        });
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}
